﻿using Entity.BaseInfo.Entity;
using Entity.BaseInfo.View.Customer;
using Entity.BaseInfo.View.Department;
using Entity.BaseInfo.View.Goods;
using Entity.BaseInfo.View.LogisticsCompany;
using Entity.BaseInfo.View.Staff;
using Entity.BaseInfo.View.Supplier;
using Entity.BaseInfo.View.Warehouse;
using Entity.BaseInfo.View.WarehousePosition;
using Entity.ERP.Entity;
using Entity.ERP.View.PurchaseArriveOrder;
using Entity.ERP.View.PurchaseArriveOrderItem;
using Entity.ERP.View.PurchaseOrder;
using Entity.ERP.View.PurchaseOrderItem;
using Entity.ERP.View.SaleDeliveryOrder;
using Entity.ERP.View.SaleDeliveryOrderItem;
using Entity.ERP.View.SaleOrder;
using Entity.ERP.View.SaleOrderItem;
using Entity.Finance.Entity;
using Entity.Finance.View.DailyReimburse;
using Entity.Finance.View.ExamineReimburse;
using Entity.Finance.View.IncomeAccount;
using Entity.Finance.View.IncomeAccountItem;
using Entity.Finance.View.IncomeManage;
using Entity.Finance.View.IncomeRefund;
using Entity.Finance.View.MonthWages;
using Entity.Finance.View.MonthWagesItem;
using Entity.Finance.View.PayAccount;
using Entity.Finance.View.PayAccountItem;
using Entity.Finance.View.PayManage;
using Entity.Finance.View.PayRefund;
using Entity.System.Entity;
using Entity.System.View.CodeRule;
using Entity.System.View.Menu;
using Entity.WMS.Entity;
using Entity.WMS.View.WarehouseBalance;
using Entity.WMS.View.WarehouseInventory;
using Entity.WMS.View.WarehouseOtherIn;
using Entity.WMS.View.WarehouseOtherOut;
using Entity.WMS.View.WarehousePurchase;
using Entity.WMS.View.WarehouseReal;
using Entity.WMS.View.WarehouseSale;
using Entity.WMS.View.WarehouseStocktaking;
using Microsoft.EntityFrameworkCore;

namespace FrameWork.DataContext
{
    public class DataContext : DbContext
    {
        /**
         * 构造函数注入
         */
        public DataContext(DbContextOptions<DataContext> options) : base(options) { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //销售订单源单
            modelBuilder.Entity<SaleOrderSourceView>()
                .HasMany(a => a.Items)
                .WithOne()
                .HasForeignKey(item => item.SaleOrderId);
        }

        /**
         * 注入数据库与模型
         */

        /**
         * 系统配置 - System
         */
        //编码规则表模型
        public DbSet<CodeRuleModel> CodeRule { get; set; }
        //编码规则表视图
        public DbSet<CodeRuleView> CodeRuleView { get; set; }
        //菜单模型
        public DbSet<MenuModel> Menu { get; set; }
        //菜单视图
        public DbSet<MenuView> MenuView { get; set; }

        /**
         * 基础信息 - BaseInfo
         */
        //员工模型
        public DbSet<StaffModel> Staff { get; set; }
        //员工视图
        public DbSet<StaffView> StaffView { get; set; }

        //部门模型
        public DbSet<DepartmentModel> Department { get; set; }
        //部门视图
        public DbSet<DepartmentView> DepartmentView { get; set; }
        //部门下拉视图
        public DbSet<DepartmentSelectView> DepartmentSelectView { get; set; }

        //客户模型
        public DbSet<CustomerModel> Customer { get; set; }
        //客户视图
        public DbSet<CustomerView> CustomerView { get; set; }

        //供应商模型
        public DbSet<SupplierModel> Supplier { get; set; }
        //供应商视图
        public DbSet<SupplierView> SupplierView { get; set; }

        //物料模型
        public DbSet<GoodsModel> Goods { get; set; }
        //物料视图
        public DbSet<GoodsView> GoodsView { get; set; }

        //仓库模型
        public DbSet<WarehouseModel> Warehouse { get; set; }
        //仓库视图
        public DbSet<WarehouseView> WarehouseView { get; set; }
        //仓库下拉视图
        public DbSet<WarehouseSelectView> WarehouseSelectView { get; set; }

        //仓位模型
        public DbSet<WarehousePositionModel> WarehousePosition { get; set; }
        //仓位视图
        public DbSet<WarehousePositionView> WarehousePositionView { get; set; }
        //仓位下拉视图
        public DbSet<WarehousePositionSelectView> WarehousePositionSelectView { get; set; }

        //物流公司模型
        public DbSet<LogisticsCompanyModel> LogisticsCompany { get; set; }
        //物流公司视图
        public DbSet<LogisticsCompanyView> LogisticsCompanyView { get; set; }

        /**
         * WMS
         */
        //其他入库单
        public DbSet<WarehouseOtherInModel> WarehouseOtherIn { get; set; }
        //其他入库单视图
        public DbSet<WarehouseOtherInView> WarehouseOtherInView { get; set; }
        //其他入库单子单
        public DbSet<WarehouseOtherInItemModel> WarehouseOtherInItem { get; set; }
        //其他入库单子单视图
        public DbSet<WarehouseOtherInItemView> WarehouseOtherInItemView { get; set; }

        //其他出库单
        public DbSet<WarehouseOtherOutModel> WarehouseOtherOut { get; set; }
        //其他出库单视图
        public DbSet<WarehouseOtherOutView> WarehouseOtherOutView { get; set; }
        //其他出库单子单
        public DbSet<WarehouseOtherOutItemModel> WarehouseOtherOutItem { get; set; }
        //其他出库单子单视图
        public DbSet<WarehouseOtherOutItemView> WarehouseOtherOutItemView { get; set; }

        //库存结存单
        public DbSet<WarehouseBalanceModel> WarehouseBalance { get; set; }
        //库存结存单视图
        public DbSet<WarehouseBalanceView> WarehouseBalanceView { get; set; }
        //库存结存子单
        public DbSet<WarehouseBalanceItemModel> WarehouseBalanceItem { get; set; }
        //库存结存子单视图
        public DbSet<WarehouseBalanceItemView> WarehouseBalanceItemView { get; set; }

        //仓库库存单
        public DbSet<WarehouseInventoryModel> WarehouseInventory { get; set; }
        //仓库库存单视图
        public DbSet<WarehouseInventoryView> WarehouseInventoryView { get; set; }

        //仓库盘点单
        public DbSet<WarehouseStocktakingModel> WarehouseStocktaking { get; set; }
        //仓库盘点单视图
        public DbSet<WarehouseStocktakingView> warehouseStocktakingView { get; set; }
        //仓库盘点单子单
        public DbSet<WarehouseStocktakingItemModel> WarehouseStocktakingItem { get; set; }
        //仓库盘点单子单视图
        public DbSet<WarehouseStocktakingItemView> WarehouseStocktakingItemView { get; set; }

        //实时库存视图
        public DbSet<WarehouseRealView> WarehouseRealView { get; set; }

        //销售出库单
        public DbSet<WarehouseSaleModel> WarehouseSale { get; set; }
        //销售出库视图
        public DbSet<WarehouseSaleView> WarehouseSaleView { get; set; }

        //采购入库单
        public DbSet<WarehousePurchaseModel> WarehousePurchase { get; set; }
        //采购入库视图
        public DbSet<WarehousePurchaseView> WarehousePurchaseView { get; set; }

        /**
         * ERP
         */

        //销售订单
        public DbSet<SaleOrderModel> SaleOrder { get; set; }
        //销售订单视图
        public DbSet<SaleOrderView> SaleOrderView { get; set; }
        //销售订单子单
        public DbSet<SaleOrderItemModel> SaleOrderItem { get; set; }
        //销售订单子单视图
        public DbSet<SaleOrderItemView> SaleOrderItemView { get; set; }
        //销售订单源单
        public DbSet<SaleOrderSourceView> SaleOrderSourceView { get; set; }

        //销售发货单
        public DbSet<SaleDeliveryModel> SaleDeliveryOrder { get; set; }
        //销售发货单视图
        public DbSet<SaleDeliveryOrderView> SaleDeliveryOrderView { get; set; }
        //销售发货子单
        public DbSet<SaleDeliveryItemModel> SaleDeliveryOrderItem { get; set; }
        //销售发货子单视图
        public DbSet<SaleDeliveryOrderItemView> SaleDeliveryOrderItemView { get; set; }

        //采购订单
        public DbSet<PurchaseOrderModel> PurchaseOrder { get; set; }
        //采购订单视图
        public DbSet<PurchaseOrderView> PurchaseOrderView { get; set; }
        //采购订单子单
        public DbSet<PurchaseOrderItemModel> PurchaseOrderItem { get; set; }
        //采购订单子单视图
        public DbSet<PurchaseOrderItemView> PurchaseOrderItemView { get; set; }

        //采购到货单
        public DbSet<PurchaseArriveOrderModel> PurchaseArriveOrder { get; set; }
        //采购到货单视图
        public DbSet<PurchaseArriveOrderView> PurchaseArriveOrderView { get; set; }
        //采购到货子单
        public DbSet<PurchaseArriveOrderItemModel> PurchaseArriveOrderItem { get; set; }
        //采购到货子单视图
        public DbSet<PurchaseArriveOrderItemView> PurchaseArriveOrderItemView { get; set; }

        /**
         * Finance
         */
        //月度工资单
        public DbSet<MonthWagesModel> MonthWages { get; set; }
        //月度工资单视图
        public DbSet<MonthWagesView> MonthWagesView { get; set; }
        //月度工资子单
        public DbSet<MonthWagesItemModel> MonthWagesItem { get; set; }
        //月度工资子单视图
        public DbSet<MonthWagesItemView> MonthWagesItemView { get; set; }

        //日常报销单
        public DbSet<DailyReimburseModel> DailyReimburse { get; set; }
        //日常报销单视图
        public DbSet<DailyReimburseView> DailyReimburseView { get; set; }

        //报销审批单
        public DbSet<ExamineReimburseModel> ExamineReimburse { get; set; }
        //报销审批单视图
        public DbSet<ExamineReimburseView> ExamineReimburseView { get; set; }

        //应收对账单
        public DbSet<IncomeAccountModel> IncomeAccount { get; set; }
        //应收对账单视图
        public DbSet<IncomeAccountView> IncomeAccountView { get; set; }
        //应收对账子单
        public DbSet<IncomeAccountItemModel> IncomeAccountItemModel { get; set; }
        //应收对账子单视图
        public DbSet<IncomeAccountItemView> IncomeAccountItemView { get; set; }

        //应收管理单
        public DbSet<IncomeManageModel> IncomeManage { get; set; }
        //应收管理单视图
        public DbSet<IncomeManageView> IncomeManageView { get; set; }

        //应收退款单
        public DbSet<IncomeRefundModel> IncomeRefund { get; set; }
        //应收退款单视图
        public DbSet<IncomeRefundView> IncomeRefundView { get; set; }

        //应付对账单
        public DbSet<PayAccountModel> PayAccount { get; set; }
        //应付对账单视图
        public DbSet<PayAccountView> PayAccountView { get; set; }
        //应付对账子单
        public DbSet<PayAccountItemModel> PayAccountItem { get; set; }
        //应付对账子单视图
        public DbSet<PayAccountItemView> PayAccountItemsView { get; set; }

        //应付管理单
        public DbSet<PayManageModel> PayManage { get; set; }
        //应付管理单视图
        public DbSet<PayManageView> PayManageView { get; set; }

        //应付退款单
        public DbSet<PayRefundModel> PayRefund { get; set; }
        //应付退款单视图
        public DbSet<PayRefundView> PayRefundView { get; set; }
    }
}
